package cn.lefull.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: qijiang
 * @date: 2019/3/8 17:58
 */
@ControllerAdvice
public class MyControllerAdvice {

    @ResponseBody
    @ExceptionHandler(value = BusinessException.class)
    public Map myErrorHandler(BusinessException be) {
        Map map = new HashMap();
        map.put("code", be.getErrorCode());
        map.put("msg", be.getData());
        return map;
    }
}
